
package ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import net.ck.hzq.R;
import net.ck.hzq.WebviewActivity;

import java.util.ArrayList;
import java.util.List;

import base.BaseViewHolder;
import base.SuperBaseAdapter;
import ui.model.CreditCardsBean;
import util.StringUtils;


/**
 * 活动专区适配器
 * Created by chenjian on 19/2/27.
 */
public class CreditCardsAdapter extends SuperBaseAdapter<CreditCardsBean> {

    List<CreditCardsBean> mData = new ArrayList<>();
    Context mContext;

    public CreditCardsAdapter(Context context, List<CreditCardsBean> data) {
        super(context, data);
        mContext = context;
        mData = data;
    }

    @Override
    protected void convert(BaseViewHolder holder, final CreditCardsBean item, final int position) {
        ImageView imageView = holder.getView(R.id.card_image);
//        imageView.setImageURI(Uri.parse(item.getImg()));
        Glide.with(mContext)
                .load(item.getImg())
                .into(imageView);
        imageView.setOnClickListener(v -> {
            if (StringUtils.isEmpty(item.getLink())) {
                return;
            }
            Intent intent = new Intent(mContext, WebviewActivity.class);
            intent.putExtra("url", item.getLink());
            intent.putExtra("type", "2");
            mContext.startActivity(intent);
        });

    }

    @Override
    protected int getItemViewLayoutId(int position, CreditCardsBean item) {
        return R.layout.item_credit_cards;
    }

}
